package engine;

import engine.planets.Planet;
import engine.planets.PlanetGenerator;
import engine.stars.RegularStar;
import engine.stars.Star;
import engine.stars.StarGenerator;

public class Sector {
	private String name;
	private Star star = null;
	private Planet[] planets = null;

	protected Sector(int x, int y, boolean isStar) {
		StarGenerator sg = StarGenerator.getInstance();
		setName(x + ":" + y);

		if (isStar == true) {
			star = sg.createNewStar();

			if (star instanceof RegularStar) {
				planets = PlanetGenerator.generatePlanets((RegularStar) star);
			}
		}
	}

	public Star getStar() {
		return star;
	}

	public Planet[] getPlanets() {
		return planets;
	}

	public Planet getPlanet(int orbit) {
		Planet planet = null;

		if (planets != null) {
			planet = planets[orbit];
		}

		return planet;
	}

	public void setPlanetSystem(Planet[] planets) {
		this.planets = planets;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
}
